package com.ellricky.teacher.ui.mycourse.leave

import android.view.View
import android.widget.AdapterView
import com.andr.common.http.callback.BaseCallback
import com.andr.common.ui.adapter.BaseRecyclerAdapter
import com.andr.common.ui.mvp.BasePresenter
import com.ellricky.baselib.cache.LocalCacheUtil
import com.ellricky.baselib.entity.new.TeachLeave
import com.ellricky.baselib.http.callback.EListCallback
import com.ellricky.baselib.ui.base.BaseRefreshActivity
import com.ellricky.baselib.util.EAppUtil
import com.ellricky.baselib.util.NewEBaseCallback
import com.ellricky.baselib.util.NewEListCallback
import com.ellricky.teacher.API_LEAVE_RECORD
import com.ellricky.teacher.LeaveAdapter
import com.ellricky.teacher.R
import com.ellricky.teacher.TcLeaveEntity

class LeaveRecordListActivity : BaseRefreshActivity<Void, BasePresenter<Void>, TeachLeave>() {

    override fun initUIView() {
        super.initUIView()
        mTvTitle.setText(R.string.tc_leave_record)
        setRightBtn(0)
    }

    override fun getResponseCallback(): BaseCallback? {
        return null
    }

    override fun getResponseCallback2(): NewEBaseCallback {
        return object : NewEListCallback<TeachLeave>(this) {
            override fun onSuccess(data: MutableList<TeachLeave>?, msg: String?) {
                dataSource = data
                rvView.onLoadFinish(data, refresh)
            }
        }
    }

    override fun getRvAdapter(): BaseRecyclerAdapter<TeachLeave> {
        return LeaveAdapter(this)
    }


    override fun initParamMap() {
        super.initParamMap()
        paramMap["action"] = "teacherLeaveList"
        paramMap["school_id"] = LocalCacheUtil.getSchoolId()
        paramMap["eid"] = LocalCacheUtil.getUid()
    }

    override fun getUrlPath(): String {
        return ""
    }

    override fun onItemClick(adapterView: AdapterView<*>?, view: View?, i: Int, l: Long) {
        super.onItemClick(adapterView, view, i, l)
        val entity = adapter[i] as TeachLeave
        EAppUtil.jumpPageWithId(this, LeaveDetailActivity::class.java, entity.leave_id.toString())
    }

    override fun onClickBtnRight() {
        super.onClickBtnRight()
        EAppUtil.jumpPageWithNoParam(this, LeaveApplyActivity::class.java)
    }
}